package arithmeticSortList;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

public class IntDemo {
	public static void main(String[] args) {
		double d2_5 = 2.5D;
		double d2_4 = 2.4D;
		double d2_6 = 2.6D;
		//double 》》 int 直接省略了小数 位。
		int int2 = 2;
		System.out.println("IntDemo:main: 2 == 2.5 "+(int2 == d2_5));//false
		System.out.println("IntDemo:main: 2 == 2.5 "+(int2 == (int)d2_5));//true

		System.out.println("IntDemo:main: 2 == 2.4 "+(int2 == d2_4));//false
		System.out.println("IntDemo:main: 2 == 2.4 "+(int2 == (int)d2_4));//true

		System.out.println("IntDemo:main: 2 == 2.6 "+(int2 == d2_6));//false
		System.out.println("IntDemo:main: 2 == 2.6 "+(int2 == (int)d2_6));//true


		float fnum = -1.0F;
		int fi = (int) fnum;
		System.out.println("fi:"+fi);

		if (1>0)return;
		new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					Thread.sleep(1000 * 1 );
					int i = 100 / 0;
					System.out.println(" zzzz");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}).start();
		System.out.println("-1 % 10 = "+(-1%10));

		float current = 38.33333F;

		BigDecimal b  =   new  BigDecimal(current);
		current   =  b.setScale(1,  BigDecimal.ROUND_HALF_UP).floatValue();
		System.out.println("current "+current);;

		float v = (float) 77 / 200;
		System.out.println("(float) 77 / 200 :"+v);

		int a = 1000;
		// 移1位 等于除以2
		// 移2位 等于除以2*2
		System.out.println("" + (a >> 1));
		String s = String.valueOf(1000);
		String substring = s.substring(0, 2);
		System.out.println(substring);

		int sum = 0;
		List<Integer> mlistInt = new ArrayList();
		mlistInt.add(1);
		mlistInt.add(2);
		mlistInt.add(3);
		mlistInt.add(4);

		for (int i = 0; i < mlistInt.size(); i += 2) {
			Integer integer = mlistInt.get(i);
			Integer integer2 = mlistInt.get(i + 1);
			sum += (integer + integer2);
			System.out.println(sum + "---");
		}

		double tempNum = 0.045345;
		// 结果 0.00
		BigDecimal bg = new BigDecimal(tempNum);
		double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
		System.out.println(f1);

		// 结果 .00
		DecimalFormat decimalFormat = new DecimalFormat("#.00");
		String format = decimalFormat.format(tempNum);
		System.out.println(format);
		double parseDouble = Double.parseDouble(format);
		System.out.println(parseDouble > 0);

		// 方法3
		// String format = String.format("%.2f", num);

		// 方法4
		// NumberFormat nf = NumberFormat.getNumberInstance();
		// nf.setMaximumFractionDigits(2);
		// String format1 = nf.format(num);

	}
}
